function digitaltochinese(num) {
  let dmap = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'];
  let declare = ['', '十', '百', '千', '万'];
  num = String(num).split('');
  let len = num.length;
  let str = '';
  let i = 0;
  if(len > 5) {
    str += digitaltochinese(num.slice(0, len - 4).join('')) + '万';
    i = len - 4;
  }
  for (; i < num.length; i++) {
    const element = num[i];
    str += dmap[element] + (element === '0' ? '' : declare[len - i - 1]);
  }
  console.log(str)
  return str;
}

digitaltochinese(1000306);